

$(function() {

// 订单操作菜单
$('.operate_box').hover(function() {
			$('.operate_list', this).show();
			$('.operate_list li').hover(function() {
						$(this).addClass('hover');
					}, function() {
						$(this).removeClass('hover');
					});
		}, function() {
			$('.operate_list', this).hide();
		});

		//取消
		$("a[id^='cancel_']").click(function() {
			var idVal = $(this).attr("name");
			var positionVal = $(this).attr("position");
			var list = art.dialog.list;
			for (var i in list) {
				list[i].close();
			}
			art.dialog({
						icon : "question",
						title : "提示",
						content : "确定要取消订单吗？",
						drag : true,
						lock : true,
						fixed : true,
						ok : function() {
							$.post("mall/order/cancel/" + positionVal + "/" + idVal, {}, function(data) {
										var icon = "succeed";
										if (!data.result)
											icon = "warning";
										list = art.dialog.list;
										for (var i in list) {
											list[i].close();
										};
										art.dialog({
													icon : icon,
													esc : true,
													content : data.message,
													lock : true,
													fixed : true,
													drag : true,
													ok : true,
													init : function() {
														var that = this, i = 10;
														var fn = function() {
															that.title(i + '秒后自动关闭');
															!i && that.close();
															i--;
														};
														tip_timer = setInterval(fn, 1000);
														fn();
													},
													close : function() {
														clearInterval(tip_timer);
														if (data.result) {
															if ("index" == positionVal)
																window.location.href = getRootUrl()+"index";
															else{
																var pageNum = $("#page").val();
																/**解决console未定义的问题*/
																if (!window.console || !console.firebug){
																	var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
																	window.console = {};
																	for (var i = 0; i < names.length; ++i)
																	window.console[names[i]] = function(){} 
																}
																console.log("page = "+console.log(pageNum));
																window.location.href = getRootUrl()+"mall/order/list?page="+pageNum+"&status="+$("#orderStatus").val()
																+"&startTime="+$("#startTime").val()+"&endTime="+$("#endTime").val();
															}
																
														}
													}
												}).time(10);
									});
						},
						cancel : true
					});
		});
		//已转账
		$("a[id^='bankTransfer_']").click(function() {
			var idVal = $(this).attr("name");
			var positionVal = $(this).attr("position");
			var list = art.dialog.list;
			for (var i in list) {
				list[i].close();
			}
			art.dialog({
						icon : "question",
						title : "提示",
						content : "确定已经转账了吗？",
						drag : true,
						lock : true,
						fixed : true,
						ok : function() {
							$.post("mall/order/bankTransfer/" + positionVal + "/" + idVal, {}, function(data) {
										var icon = "succeed";
										if (!data.result)
											icon = "warning";
										list = art.dialog.list;
										for (var i in list) {
											list[i].close();
										};
										art.dialog({
													icon : icon,
													esc : true,
													content : data.message,
													lock : true,
													fixed : true,
													drag : true,
													ok : true,
													init : function() {
														var that = this, i = 10;
														var fn = function() {
															that.title(i + '秒后自动关闭');
															!i && that.close();
															i--;
														};
														tip_timer = setInterval(fn, 1000);
														fn();
													},
													close : function() {
														clearInterval(tip_timer);
														if (data.result) {
															if ("index" == positionVal)
																window.location.href = getRootUrl()+"index";
															else{
																var pageNum = $("#page").val();
																/**解决console未定义的问题*/
																if (!window.console || !console.firebug){
																	var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
																	window.console = {};
																	for (var i = 0; i < names.length; ++i)
																	window.console[names[i]] = function(){} 
																}
																console.log("page = "+console.log(pageNum));
																window.location.href = getRootUrl()+"mall/order/list?page="+pageNum+"&status="+$("#orderStatus").val()
																+"&startTime="+$("#startTime").val()+"&endTime="+$("#endTime").val();
															}
																
														}
													}
												}).time(10);
									});
						},
						cancel : true
					});
		});
		
			//-------已收发票
		$("a[id^='receiptInvoice_']").click(function() {
			var orderNoVal = $(this).attr("name");
			var positionVal = $(this).attr("position");
			var list = art.dialog.list;
			for (var i in list) {
				list[i].close();
			}
		
			$.post("mall/order/receiptInvoice/" + positionVal + "/" + orderNoVal, {}, function(data) {
						var icon = "succeed";
						if (!data.result)
							icon = "warning";
						list = art.dialog.list;
						for (var i in list) {
							list[i].close();
						};
						art.dialog({
									icon : icon,
									esc : true,
									content : data.message,
									lock : true,
									fixed : true,
									drag : true,
									ok : true,
									init : function() {
										var that = this, i = 10;
										var fn = function() {
											that.title(i + '秒后自动关闭');
											!i && that.close();
											i--;
										};
										tip_timer = setInterval(fn, 1000);
										fn();
									},
									close : function() {
										clearInterval(tip_timer);
										if (data.result) {
											if ("index" == positionVal)
												window.location.href = getRootUrl()+"index";
											else{
												var pageNum = $("#page").val();
												/**解决console未定义的问题*/
												if (!window.console || !console.firebug){
													var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
													window.console = {};
													for (var i = 0; i < names.length; ++i)
													window.console[names[i]] = function(){} 
												}
												console.log("page = "+console.log(pageNum));
												window.location.href = getRootUrl()+"mall/order/list?page="+pageNum+"&status="+$("#orderStatus").val()
												+"&startTime="+$("#startTime").val()+"&endTime="+$("#endTime").val();
											}
												
										}
									}
								}).time(10);
					});
					
		});
	});
